import request from '../baseRequest.js'
const baseURL = '/provide/user'
//发送验证码注册
export function smsCode(data) {
	let baseDefaultOpts = {
		url: baseURL + '/sendCode',
		// 请求接口地址
		data: data,
		// 传入请求参数
		method: 'get',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}
//忘记密码
export function forgetCode(data) {
	let baseDefaultOpts = {
		url: baseURL + '/smsSend',
		// 请求接口地址
		data: data,
		// 传入请求参数
		method: 'get',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}
//重置密码
export function forget(data) {
	let baseDefaultOpts = {
		url: baseURL + '/forget',
		// 请求接口地址
		data: data,
		// 传入请求参数
		method: 'post',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}

export function regist(data) {
	let baseDefaultOpts = {
		url: baseURL + '/register',
		// 请求接口地址
		data: data,
		// 传入请求参数
		method: 'post',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}

export function login(data) {
	let baseDefaultOpts = {
		url: baseURL + '/login',
		// 请求接口地址
		data: data,
		// 传入请求参数
		method: 'post',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}

export function getInfo() {
	let _token = uni.getStorageSync("token")
	// uni.getStorageSync({
	// 	key: 'token',
	// 	success: function(res) {
	// 		_token = res.data
	// 	}
	// });
	let baseDefaultOpts = {
		url: baseURL + '/getInfo',
		// 请求接口地址
		method: 'post',
		// 配置请求类型
		header: {
			'token': _token,
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}

export function save(data) {
	// let _token = uni.getStorageSync("token")
	// uni.getStorageSync({
	// 	key: 'token',
	// 	success: function(res) {
	// 		_token = res.data
	// 	}
	// });
	let baseDefaultOpts = {
		url: baseURL + '/save',
		// 请求接口地址
		method: 'post',
		// 配置请求类型
		data: data,
		header: {
			// 'token': _token,
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}

export function attestation(data){
	let baseDefaultOpts = {
		url: baseURL + '/update',
		// 请求接口地址
		data: data,
		// 传入请求参数
		method: 'post',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}
//退出登录
export function outLogin(data){
	let baseDefaultOpts = {
		url: baseURL + '/outLogin',
		// 请求接口地址
		method: 'get',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}

//修改密码
export function updatePassword(data){
	let baseDefaultOpts = {
		url: baseURL + '/updatePassword',
		// 请求接口地址
		method: 'post',
		// 配置请求类型
		header: {
			'X-Requested-With': 'XMLHttpRequest',
			"Accept": "application/json",
			"Content-Type": "application/json; charset=UTF-8"
		},
	}
	return request(baseDefaultOpts)
}
